package cn.myproject.articletype.service.impl;
import cn.myproject.articletype.domian.Article;
import cn.myproject.articletype.mapper.ArticleMapper;
import cn.myproject.articletype.query.ArticleQuery;
import cn.myproject.articletype.service.IArticleservice;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ArticleserviceImpl implements IArticleservice {
    @Autowired
    private ArticleMapper articleMapper;

    //新增
    @Override
    public void addArticle(Article article) {
        articleMapper.addArticle(article);
    }
    //修改
    @Override
    public void updata(Article article) {
        articleMapper.updata(article);
    }
    //查询一个按照id
    @Override
    public Article selectByid(Long id) {
        return articleMapper.selectByid(id);
    }
    //分页查询
    @Override
    public PageInfo<Article> selectAll(ArticleQuery articleQuery) {
        PageHelper.startPage(articleQuery.getCurrentPage(), articleQuery.getPageSize());
        //按名字进行条件查询
        List<Article> list = articleMapper.selectbyName(articleQuery);
        PageInfo<Article> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
    //批量删除
    @Override
    public void delectall(List<Long> ids) {
        articleMapper.delectall(ids);

    }
    //按id删除
    @Override
    public void delectByid(Long id) {
        articleMapper.delectByid(id);
    }

}
